import requests 
import sys
sys.path.append('..')
from main.utils.util_json import get_json_from_file

header = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJxeWFwaS5xaXl1Y2xvdWQuY29tLmNuIiwiaWF0IjoxNzE2OTY0NjEyLCJzdWIiOiJ7XCJjbGllbnRUeXBlXCI6MTMsXCJkYXRhU3RvcmFnZU1vZGVsXCI6MixcInN0b3JlSWRcIjozLFwidGVuYW50SWRcIjoxMDAxNjUsXCJ1c2VySWRcIjoyNTk1fSIsImV4cCI6MTcxNzU2OTU5MiwibmJmIjoxNzE2OTY0NjEyfQ.HeukQhFOem-FO6wHhmbRFkqkEAwBfTedZ9JrqERbKP8'
    }
# payload={"account_id": "", "data_type": "2", "level": "1/13", "tenant_id": "103818", "interface_type": "1", "page_size": 10, "operate_type": "1", "platform_type": "1", "sort_type": "8", "period_end": "2024-05-29", "period_start": "2024-05-01", "export_type": "1", "page_no": 1}



def test_interface(interface_code, payload):
    url_prefix=f'http://118.145.151.16/etlctl/reportdata/?interface_code={interface_code}'
    resp=requests.post(url=url_prefix, headers=header, json=payload)
    print(resp.json().get('message'))

f= get_json_from_file('./demo_interface.json')
payload = f.get('param')
for interface_code in f.get('interface_code'):
    # print(interface_code)
    test_interface(interface_code, payload)